package com.globalblue;

import java.io.File;
import java.io.IOException;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.util.Zip4jConstants;

import org.apache.commons.io.FileUtils;

public class BackupManager {
	public void backupFolder(String source, String destination) throws IOException {
		FileUtils.copyDirectory(new File(source), new File(destination));
	}

	public void zipFolder(String source, String destination) {
		try {
			ZipFile zipFile = new ZipFile(destination);
			String folderToAdd = source;
			ZipParameters parameters = new ZipParameters();
			parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
			parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_MAXIMUM);
			zipFile.addFolder(folderToAdd, parameters);
		} catch (ZipException e) {
			e.printStackTrace();
		}
	}
}
